Introduce GtkAccessible
authorEmmanuele Bassi <ebassi@gnome.org>
Tue, 16 Jun 2020 16:40:14 +0000 (17:40 +0100)
committerEmmanuele Bassi <ebassi@gnome.org>
Sun, 26 Jul 2020 19:31:14 +0000 (20:31 +0100)
GtkAccessible is an interface for accessible UI elements.

Currently, it doesn't do much except exist as a type; in the future, it
will be the entry point for all accessible state in GTK.

gtk/gtk.h
gtk/gtkaccessible.c [new file with mode: 0644]
gtk/gtkaccessible.h [new file with mode: 0644]
gtk/gtkwidget.c
gtk/meson.build

index bc689f2e2b0bbd34006520a5e556f52499be14d8..2277e1136d531de55af4c4931c1bb20e6543ea3f 100644 (file)
--- a/gtk/gtk.h
+++ b/gtk/gtk.h
@@ -34,6 +34,7 @@
 #include <gtk/gtkaboutdialog.h>
 #include <gtk/gtkaccelgroup.h>
 #include <gtk/gtkaccellabel.h>
+#include <gtk/gtkaccessible.h>
 #include <gtk/gtkactionable.h>
 #include <gtk/gtkactionbar.h>
 #include <gtk/gtkadjustment.h>
diff --git a/gtk/gtkaccessible.c b/gtk/gtkaccessible.c
new file mode 100644 (file)
index 0000000..d8187b6
--- /dev/null
@@ -0,0 +1,30 @@
+/* gtkaccessible.c: Accessible interface
+ *
+ * Copyright 2020  GNOME Foundation
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gtkaccessible.h"
+
+G_DEFINE_INTERFACE (GtkAccessible, gtk_accessible, G_TYPE_OBJECT)
+
+static void
+gtk_accessible_default_init (GtkAccessibleInterface *iface)
+{
+}
diff --git a/gtk/gtkaccessible.h b/gtk/gtkaccessible.h
new file mode 100644 (file)
index 0000000..d54d21a
--- /dev/null
@@ -0,0 +1,39 @@
+/* gtkaccessible.h: Accessible interface
+ *
+ * Copyright 2020  GNOME Foundation
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <glib-object.h>
+#include <gtk/gtktypes.h>
+#include <gtk/gtkenums.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_ACCESSIBLE (gtk_accessible_get_type())
+
+GDK_AVAILABLE_IN_ALL
+G_DECLARE_INTERFACE (GtkAccessible, gtk_accessible, GTK, ACCESSIBLE, GObject)
+
+struct _GtkAccessibleInterface
+{
+  GTypeInterface g_iface;
+};
+
+G_END_DECLS
index 56104548f29c3fa723553b393229713a6b0e3d51..9013ad66613914c07bacb5811a2bbb67c2f05c38 100644 (file)
@@ -27,6 +27,7 @@
 #include "gtkwidgetprivate.h"
 
 #include "gtkaccelgroupprivate.h"
+#include "gtkaccessible.h"
 #include "gtkactionobserverprivate.h"
 #include "gtkapplicationprivate.h"
 #include "gtkbuildable.h"
@@ -599,6 +600,8 @@ static void             gtk_widget_real_measure                 (GtkWidget
 static void             gtk_widget_real_state_flags_changed     (GtkWidget        *widget,
                                                                  GtkStateFlags     old_state);
 
+static void             gtk_widget_accessible_interface_init    (GtkAccessibleInterface *iface);
+
 static void             gtk_widget_buildable_interface_init     (GtkBuildableIface  *iface);
 static void             gtk_widget_buildable_set_name           (GtkBuildable       *buildable,
                                                                  const char         *name);
@@ -680,6 +683,13 @@ gtk_widget_get_type (void)
        NULL,           /* value_table */
       };
 
+      const GInterfaceInfo accessible_info =
+      {
+        (GInterfaceInitFunc) gtk_widget_accessible_interface_init,
+        (GInterfaceFinalizeFunc) NULL,
+        NULL,
+      };
+
       const GInterfaceInfo buildable_info =
       {
        (GInterfaceInitFunc) gtk_widget_buildable_interface_init,
@@ -702,10 +712,12 @@ gtk_widget_get_type (void)
       GtkWidget_private_offset =
         g_type_add_instance_private (widget_type, sizeof (GtkWidgetPrivate));
 
+      g_type_add_interface_static (widget_type, GTK_TYPE_ACCESSIBLE,
+                                   &accessible_info);
       g_type_add_interface_static (widget_type, GTK_TYPE_BUILDABLE,
-                                   &buildable_info) ;
+                                   &buildable_info);
       g_type_add_interface_static (widget_type, GTK_TYPE_CONSTRAINT_TARGET,
-                                   &constraint_target_info) ;
+                                   &constraint_target_info);
     }
 
   return widget_type;
@@ -8038,6 +8050,14 @@ gtk_widget_set_vexpand_set (GtkWidget      *widget,
   gtk_widget_set_expand_set (widget, GTK_ORIENTATION_VERTICAL, set);
 }
 
+/*
+ * GtkAccessible implementation
+ */
+static void
+gtk_widget_accessible_interface_init (GtkAccessibleInterface *iface)
+{
+}
+
 /*
  * GtkBuildable implementation
  */
index 4ad1796e625bec486c0cec4cd868eb44df97f699..db3f8c178f52990bb1982c10540aa02851ef3bb3 100644 (file)
@@ -149,6 +149,7 @@ gtk_public_sources = files([
   'gtkaboutdialog.c',
   'gtkaccelgroup.c',
   'gtkaccellabel.c',
+  'gtkaccessible.c',
   'gtkactionable.c',
   'gtkactionbar.c',
   'gtkadjustment.c',
@@ -436,6 +437,7 @@ gtk_public_headers = files([
   'gtkaboutdialog.h',
   'gtkaccelgroup.h',
   'gtkaccellabel.h',
+  'gtkaccessible.h',
   'gtkactionable.h',
   'gtkactionbar.h',
   'gtkadjustment.h',